﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LibrarySysPrototype
{
    public partial class AdminUI : Form
    {
        public AdminUI()
        {
            InitializeComponent();
        }

        private void AdminUI_Load(object sender, EventArgs e)
        {
            clearStatus();
            ApplyChangeButton.Enabled = false;
            SubmitButton.Enabled = false;
        }

        private void SubmitButton_Click(object sender, EventArgs e)
        {
            //link this with db

            if (AddRadioButton.Checked)
            {
                AddStatusLabel.Visible = true;
            }
            if (EditRadioButton.Checked)
            {
                SubmitButton.Enabled = false;
                StatusInfoLabel.Visible = true;
                ApplyChangeButton.Enabled = true;
                EditTypeComboBox.Visible = true;
                EditTypeLabel.Visible = true;
                EditNameTextBox.Visible = true;
                EditNameLabel.Visible = true;
                EditNameTextBox.Text = NameTextBox.Text;
                EditTypeComboBox.Text = TypeComboBox.Text;
            }
            if (DeleteRadioButton.Checked)
            {
                DeleteStatusLabel.Visible = true;
            }
        }

        private void AddRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            clearStatus();
            SubmitButton.Enabled = true;
        }

        private void EditRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            clearStatus();
            SubmitButton.Enabled = true;
        }

        private void DeleteRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            clearStatus();
            SubmitButton.Enabled = true;
        }

        private void ApplyChangeButton_Click(object sender, EventArgs e)
        {
            ApplyChangeButton.Enabled = false;
            SubmitButton.Enabled = false;
            clearStatus();
        }

        private void clearStatus()
        {
            DeleteStatusLabel.Visible = false;
            AddStatusLabel.Visible = false;
            StatusInfoLabel.Visible = false;
            EditTypeComboBox.Visible = false;
            EditTypeLabel.Visible = false;
            EditNameTextBox.Visible = false;
            EditNameLabel.Visible = false;
        }
    }
}
